<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "login.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  
  return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?php require_once('../Connections/miportal.php');
mysql_query("SET NAMES 'utf8'");
mysql_select_db($database_miportal, $miportal);
$query_rs_corte02 = "SELECT DISTINCT usuario.`id_target`, usuario.`nmb_target`,usuario.`nmb_titulo`, usuario.`nmb_nombres`, usuario.`nmb_apaterno`, usuario.`nmb_amaterno`, COUNT(candidato.id_cat_ies) AS CONTADOR,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=17 AND cor_candidato.id_cat_ies=usuario.id_target) AS VAL_VB,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=17 AND cor_candidato.id_cat_ies=usuario.id_target AND cor_candidato.tp_stat_registro='COMPLETO') AS COMP_VB,
(select COUNT(*) from cor_candidato JOIN cor_ben_ies_emp AS bie ON(cor_candidato.id_cor_candidato=bie.id_cor_candidato) WHERE id_convocatoria_activa=17 AND cor_candidato.id_cat_ies=usuario.id_target AND bie.tp_status_validacion=1) AS VAL_VB,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=18 AND cor_candidato.id_cat_ies=usuario.id_target) AS VAL_EXP,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=18 AND cor_candidato.id_cat_ies=usuario.id_target AND cor_candidato.tp_stat_registro='COMPLETO') AS COMP_EXP,
(select COUNT(*) from cor_candidato JOIN cor_ben_ies_emp AS bie ON(cor_candidato.id_cor_candidato=bie.id_cor_candidato) WHERE id_convocatoria_activa=18 AND cor_candidato.id_cat_ies=usuario.id_target AND bie.tp_status_validacion=1) AS VAL_EXP,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=19 AND cor_candidato.id_cat_ies=usuario.id_target) AS VAL_EMP,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=19 AND cor_candidato.id_cat_ies=usuario.id_target AND cor_candidato.tp_stat_registro='COMPLETO') AS COMP_EMP,
(select COUNT(*) from cor_candidato JOIN cor_ben_ies_emp AS bie ON(cor_candidato.id_cor_candidato=bie.id_cor_candidato) WHERE id_convocatoria_activa=19 AND cor_candidato.id_cat_ies=usuario.id_target AND bie.tp_status_validacion=1) AS VAL_EMP,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=20 AND cor_candidato.id_cat_ies=usuario.id_target) AS VAL_MPE,
(select COUNT(*) from cor_candidato WHERE id_convocatoria_activa=20 AND cor_candidato.id_cat_ies=usuario.id_target AND cor_candidato.tp_stat_registro='COMPLETO') AS COMP_MPE,
(select COUNT(*) from cor_candidato JOIN cor_ben_ies_primaria AS bip  ON(cor_candidato.id_cor_candidato=bip.id_cor_candidato) WHERE id_convocatoria_activa=20 AND cor_candidato.id_cat_ies=usuario.id_target AND bip.tp_status_validacion=1) AS VAL_MPE
FROM cat2_usuario AS usuario  LEFT JOIN cor_candidato AS candidato ON(usuario.id_target=candidato.id_cat_ies) WHERE usuario.tp_perfil='RIV'  AND usuario.tp_validacion=11 GROUP BY usuario.id_target ORDER BY CONTADOR DESC";
$rs_corte02 = mysql_query($query_rs_corte02, $miportal) or die(mysql_error());
$row_rs_corte02 = mysql_fetch_assoc($rs_corte02);
$totalRows_rs_corte02 = mysql_num_rows($rs_corte02);
?>

<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximun-scale=1">
<title>FUNDACIÓN EDUCACIÓN SUPERIOR-EMPRESA</title>
<!--Hoja de estilo principal-->
<link href="../css/styletd2.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/menu.css"><!--Pemanggilan gambar favicon-->
<link rel="stylesheet" type="text/css" href="../css/mos-style.css">
 <!--pemanggilan file css-->
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>
<body>

<div id="background">
</div>

 
 <header>
    
    <div class="img_header_logo"></div>
    <span class="img_header_logo"><a href="http://fese.org.mx"><img src="../images/fese/FESE_home_logo.png"  height="90" alt="FESE" align="bottom" /></a></span>
    <div class="img_header_logo"></div>
    
  
<div id="nav">
<ul>
  <li class="nivel1"><a href="../private/dva.php" class="nivel1">Inicio</a></li>
  <li class="nivel1"><a href="../report/report_dva_candidatos.php" class="nivel1">Candidatos</a></li>
  <?php if($_SESSION['MM_tp_programa']!="MI PRIMERA EMPRESA"){
			  echo 
			  		'<li class="nivel1"><a href="../report/report_dva_empresa.php" class="nivel1">Empresas</a></li>';
			 		 }	
		  
		  ?>
	
</ul>
</div><!--Menu NAV-->

</header>

<center>
<div id="boxcontainer">
<div id="container">
  <p>&nbsp;</p>
  
  
  
  <div id="dinamicContaint">
  <table width="100%" border="1">   
	  <th class="data" scope="col">#</th>
      <th class="data" scope="col">IES</th>
      <th class="data" scope="col">NOMBRE RIV</th>
      <th class="data" scope="col">TOTAL</th>
      <th class="data" scope="col">BV</th>
      <th class="data" scope="col">EXP</th>
      <th class="data" scope="col">EMP</th>
      <th class="data" scope="col">MPE</th>
   <?php 
   $counter=1;
   do { ?>
   
   <tr>
     <td class="data" style="width:10px;"><?php echo $counter; ?></td>
     <td class="data" style="width:250px;"><?php echo $row_rs_corte02['nmb_target']; ?></td>
     <td class="data" style="width:150px;"><?php echo $row_rs_corte02['nmb_titulo']; ?><?php echo $row_rs_corte02['nmb_nombres']; ?> <?php echo $row_rs_corte02['nmb_apaterno']; ?></td>
     <td class="data" style="width:15px"><?php echo ($row_rs_corte02['VAL_VB']+$row_rs_corte02['VAL_EXP']+$row_rs_corte02['VAL_EMP']+$row_rs_corte02['VAL_MPE'])."/".$row_rs_corte02['CONTADOR']; ?></td>
     <td class="data" style="width:15px"><?php 
	 echo "<a href='../report/report_dva_candidatos.php?id_ies=".$row_rs_corte02['id_target']."&id_convocatoria=17&update=true&ies=".base64_encode($row_rs_corte02['nmb_target'])."'>".$row_rs_corte02['VAL_VB']."</a>"; ?></td>
     <td class="data" style="width:15px"><?php 
	 echo "<a href='../report/report_dva_candidatos.php?id_ies=".$row_rs_corte02['id_target']."&id_convocatoria=18&update=true&ies=".base64_encode($row_rs_corte02['nmb_target'])."'>".$row_rs_corte02['VAL_EXP']."</a>"; ?></td>
     <td class="data" style="width:15px"><?php 
	 echo "<a href='../report/report_dva_candidatos.php?id_ies=".$row_rs_corte02['id_target']."&id_convocatoria=19&update=true&ies=".base64_encode($row_rs_corte02['nmb_target'])."'>".$row_rs_corte02['VAL_EMP']."</a>"; ?></td>
     <td class="data" style="width:15px"><?php 
	 echo "<a href='../report/report_dva_candidatos.php?id_ies=".$row_rs_corte02['id_target']."&id_convocatoria=20&update=true&ies=".base64_encode($row_rs_corte02['nmb_target'])."'>".$row_rs_corte02['VAL_MPE']."</a>"; ?></td>
     
     
     </tr>
     
     <?php 
	 $counter++;
	 } while ($row_rs_corte02 = mysql_fetch_assoc($rs_corte02)); ?>
 </table>
<p>&nbsp;</p>
  </div><!--dinamicContaint-->
  
  
  
  
  
  
  <p>&nbsp;</p>
</div><!--Container-->
<div id="rightContainer">
    <div id="Bienvenida">
    <div id="cuadro">
    <h1>Bienvenido</h1>
    </div>
    
    <div >
    <br>
            <?php echo $_SESSION['MM_UsName'] ?><br><br>
            <?php echo $_SESSION['MM_nmb_target'] ?><br>
            <a href="<?php echo $logoutAction ?>">Salir</a>
            </div>
    </div>
    <br style="clear:both"/>
    <div id="convocatoria">
    <div id="cuadro">
    <h1>Convocatoria</h1>
    </div>
    <br>
    <?php 
    if(isset($_SESSION['MM_tp_programa'])&$_SESSION['MM_tp_programa']=="Vigentes"){
        echo "<select name=\"slConvocatoria\">
        <option selected=\"selected\">Seleccione</option>
        <option value=\"empleate\">Empleate</option>
        <option value=\"experimenta\">Experimenta</option>
        <option value=\"mpe\">Mi Primera Empresa</option>
        <option value=\"vecas_vinculacion\">Vecas Vinculación</option>
        </select>
        "	;
    }else{
    echo $_SESSION['MM_tp_programa'];}
    ?>
    
    </div>
</div><!--contenedor derecho-->


</div><!--Boxcontainer-->
  
   
</center>
  
  
</body>
</html>

